package com.ruibang.glass.quality.controller;

import com.ruibang.glass.quality.domain.req.SchedulingReportReq;
import com.ruibang.glass.quality.entity.SchedulingReport;
import com.ruibang.glass.quality.service.SchedulingReportService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author: songJinKang
 * @CreateTime: 2023-09-18  10:03
 * @Description: TODO
 * @Version: 1.0
 */

@RestController
@RequestMapping("/api/scheduling/report")
@Api(value = "调度报表控制器", tags = {"调度报表控制器"})
public class SchedulingReportController {

    @Autowired
    private SchedulingReportService schedulingReportService;


    @PostMapping("/save")
    @ApiOperation(value = "保存调度表任务", notes = "保存调度表任务")
    public ResultBody save(@RequestBody @Valid SchedulingReport schedulingReport) {
        return schedulingReportService.insert(schedulingReport);
    }

    @PostMapping("/querySchedulingReport")
    @ApiOperation(value = "查询调度表任务", notes = "查询调度表任务")
    public ResultBody querySchedulingReport(@RequestBody SchedulingReportReq schedulingReportReq) {
        return schedulingReportService.querySchedulingReport(schedulingReportReq);
    }

    @PostMapping("/edit")
    @ApiOperation(value = "修改调度表任务", notes = "修改调度表任务")
    public ResultBody edit(@RequestBody @Valid SchedulingReport schedulingReport) {
        return schedulingReportService.edit(schedulingReport);
    }

    @GetMapping("/getDetail/{id}")
    @ApiOperation(value = "根据id获取详情", notes = "根据id获取详情")
    public ResultBody getDetail(@PathVariable String id) {
        return schedulingReportService.getDetail(id);
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "根据id删除", notes = "根据id删除")
    public ResultBody deleteById(@PathVariable String id) {
        schedulingReportService.removeById(id);
        return ResultBody.success();
    }

    @PostMapping("/getGlassData")
    @ApiOperation(value = "根据日期获取玻璃数据", notes = "根据日期获取玻璃数据")
    public ResultBody getGlassData(@RequestBody SchedulingReportReq schedulingReportReq) {
        return schedulingReportService.getGlassData(schedulingReportReq);
    }
}
